﻿using System;
using System.Configuration.Install;
using System.ComponentModel;
using System.ServiceProcess;

namespace BizElements.Services.Windows
{
    /// <summary>Installs Windows Service which hosts the remoting WCF services.</summary>
    [RunInstaller(true)]
    public class RpcServiceInstaller : Installer
    {
        /// <summary>Service name. Should be unique on a host.</summary>
        public const string RpcServiceName = "Northwind RPC Service";

        /// <summary>Required designer variable.</summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>Constructor.</summary>
        public RpcServiceInstaller()
        {
            var processInstaller = new ServiceProcessInstaller()
            {
                Account = ServiceAccount.LocalSystem
            };

            var serviceInstaller = new ServiceInstaller()
            {
                DisplayName = RpcServiceName,
                ServiceName = RpcServiceName,
                StartType = ServiceStartMode.Automatic
            };

            this.Installers.Add(processInstaller);
            this.Installers.Add(serviceInstaller);
        }

        /// <summary>Clean up any resources being used.</summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        /// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
        }
    }
}
